package com.zkh.myutils.bean;

import java.math.BigDecimal;
import java.math.BigInteger;
/**
 * 基础类型数组
 * @author zkh
 */
public enum ArrayClass {
	BaseByte("byte[]", "[B", byte.class),
	BaseShort("short[]", "[S", short.class),
	BaseInt("int[]", "[I", int.class),
	BaseLong("long[]", "[J", long.class),
	BaseFloat("float[]", "[F", float.class),
	BaseDouble("double[]", "[D", double.class),
	BaseChar("char[]", "[C", char.class),
	BaseBoolean("boolean[]", "[Z", boolean.class),
	Byte("Byte[]", "[Ljava.lang.Byte;", Byte.class),
	Short("Short[]", "[Ljava.lang.Short;", Short.class),
	Integer("Integer[]", "[Ljava.lang.Integer;", Integer.class),
	Long("Long[]", "[Ljava.lang.Long;", Long.class),
	Float("Float[]", "[Ljava.lang.Float;", Float.class),
	Double("Double[]", "[Ljava.lang.Double;", Double.class),
	Character("Character[]", "[Ljava.lang.Character;", Character.class),
	Boolean("Boolean[]", "[Ljava.lang.Boolean;", Boolean.class),
	BigInteger("BigInteger[]", "[Ljava.math.BigInteger;", BigInteger.class),
	BigDecimal("BigDecimal[]", "[Ljava.math.BigDecimal;", BigDecimal.class);

	/**
	 * 原数组类型
	 */
	public String origin;
	/**
	 * 数组的Class名称
	 */
	public String clazz;
	/**
	 * 数组类型class
	 */
	public Class<?> cls;
	private ArrayClass(String origin, String clazz, Class<?> cls){
		this.origin = origin;
		this.clazz = clazz;
		this.cls = cls;
	}
	
	/**
	 * 根据className获取ArrayClass枚举对象
	 * @param className 类名
	 * @return
	 */
	public static ArrayClass getArrayClassByclass(String className) {
		for(ArrayClass arrayClass: ArrayClass.values()) {
			if(arrayClass.clazz.equals(className)) {
				return arrayClass;
			}
		}
		return null;
	}
	
	/**
	 * 是否为可解析数组
	 * @param className 类名
	 */
	public static boolean inArrayClass(String className) {
		for(ArrayClass arrayClass: ArrayClass.values()) {
			if(arrayClass.clazz.equals(className)) {
				return true;
			}
		}
		return false;
	}
}
